home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / forth.vim < prev    next >
Encoding:
Text File  |  2001-09-12  |  6.5 KB  |  189 lines

  1. " Vim syntax file
  2. " Language   : FORTH
  3. " Maintainer : Christian V. J. Brüssow <cvjb@epost.de>
  4. " Last change: Son 06 Mai 2001 20:16:25 CEST
  5.  
  6. " Thanks to...
  7. "
  8. " John Providenza <john@probo.com> made some improvements
  9. " for the highlighting of strings, and added the code for
  10. " highlighting hex numbers.
  11.  
  12.  
  13. " The list of keywords is incomplete, compared with the offical ANS
  14. " wordlist. If you use this language, please improve it, and send me
  15. " the patches.
  16.  
  17. " For version 5.x: Clear all syntax items
  18. " For version 6.x: Quit when a syntax file was already loaded
  19. if version < 600
  20.     syntax clear
  21. elseif exists("b:current_syntax")
  22.     finish
  23. endif
  24.  
  25. " Synchronization method
  26. syn sync ccomment maxlines=200
  27.  
  28. " I use gforth, so I set this to case ignore
  29. syn case ignore
  30.  
  31. " Some special, non-FORTH keywords
  32. syn keyword forthTodo contained TODO FIXME
  33. syn match forthTodo contained 'Copyright\(\s([Cc])\)\=\(\s[0-9]\{2,4}\)\='
  34.  
  35. " Characters allowed in keywords
  36. " I don't know if 128-255 are allowed in ANS-FORHT
  37. if version >= 600
  38.     setlocal iskeyword=!,@,33-64,A-Z,91-96,a-z,123-126,128-255
  39. else
  40.     set iskeyword=!,@,33-64,A-Z,91-96,a-z,123-126,128-255
  41. endif
  42.  
  43.  
  44. " Keywords
  45.  
  46. " basic mathematical and logical operators
  47. syn keyword forthOperators + - * / MOD /MOD NEGATE ABS MIN MAX
  48. syn keyword forthOperators AND OR XOR NOT INVERT 2* 2/ 1+ 1- 2+ 2- 8*
  49. syn keyword forthOperators M+ */ */MOD M* UM* M*/ UM/MOD FM/MOD SM/REM
  50. syn keyword forthOperators D+ D- DNEGATE DABS DMIN DMAX
  51. syn keyword forthOperators F+ F- F* F/ FNEGATE FABS FMAX FMIN FLOOR FROUND
  52. syn keyword forthOperators F** FSQRT FEXP FEXPM1 FLN FLNP1 FLOG FALOG FSIN
  53. syn keyword forthOperators FCOS FSINCOS FTAN FASIN FACOS FATAN FATAN2 FSINH
  54. syn keyword forthOperators FCOSH FTANH FASINH FACOSH FATANH
  55. syn keyword forthOperators 0< 0<= 0<> 0= 0> 0>= <= <> = > >=
  56.  
  57. " stack manipulations
  58. syn keyword forthStack DROP NIP DUP OVER TUCK SWAP ROT -ROT ?DUP PICK ROLL
  59. syn keyword forthStack 2DROP 2NIP 2DUP 2OVER 2TUCK 2SWAP 2ROT
  60. syn keyword forthStack 3DUP 4DUP
  61. syn keyword forthRStack >R R> R@ RDROP 2>R 2R> 2R@ 2RDROP
  62. syn keyword forthFStack FDROP FNIP FDUP FOVER FTUCK FSWAP FROT
  63.  
  64. " stack pointer manipulations
  65. syn keyword forthSP SP@ SP! FP@ FP! RP@ RP! LP@ LP!
  66.  
  67. " address operations
  68. syn keyword forthMemory @ ! +! C@ C! 2@ 2! F@ F! SF@ SF! DF@ DF!
  69. syn keyword forthAdrArith CHARS CHAR+ CELLS CELL+ CELL ALIGN ALIGNED FLOATS
  70. syn keyword forthAdrArith FLOAT+ FLOAT FALIGN FALIGNED SFLOATS SFLOAT+
  71. syn keyword forthAdrArith SFALIGN SFALIGNED DFLOATS DFLOAT+ DFALIGN DFALIGNED
  72. syn keyword forthAdrArith MAXALIGN MAXALIGNED CFALIGN CFALIGNED
  73. syn keyword forthAdrArith ADDRESS-UNIT-BITS ALLOT ALLOCATE HERE
  74. syn keyword forthMemBlks MOVE ERASE CMOVE CMOVE> FILL BLANK
  75.  
  76. " conditionals
  77. syn keyword forthCond IF ELSE ENDIF THEN CASE OF ENDOF ENDCASE ?DUP-IF
  78. syn keyword forthCond ?DUP-0=-IF AHEAD CS-PICK CS-ROLL CATCH THROW
  79.  
  80. " iterations
  81. syn keyword forthLoop BEGIN WHILE REPEAT UNTIL AGAIN
  82. syn keyword forthLoop ?DO LOOP I J K +DO U+DO -DO U-DO DO +LOOP -LOOP
  83. syn keyword forthLoop UNLOOP LEAVE ?LEAVE EXIT DONE FOR NEXT
  84.  
  85. " new words
  86. syn match forthColonDef '\<:\s*[^ \t]\+\>'
  87. syn keyword forthEndOfColonDef ;
  88. syn keyword forthDefine CONSTANT 2CONSTANT FCONSTANT VARIABLE 2VARIABLE CREATE
  89. syn keyword forthDefine USER VALUE TO DEFER IS DOES> IMMEDIATE COMPILE-ONLY
  90. syn keyword forthDefine COMPILE RESTRICT INTERPRET POSTPONE EXECUTE LITERAL
  91. syn keyword forthDefine CREATE-INTERPRET/COMPILE INTERPRETATION> <INTERPRETATION
  92. syn keyword forthDefine COMPILATION> <COMPILATION ] LASTXT COMP' POSTPONE,
  93. syn keyword forthDefine FIND-NAME NAME>INT NAME?INT NAME>COMP NAME>STRING STATE
  94. syn match forthDefine "\[COMP']"
  95. syn match forthDefine "'"
  96. syn match forthDefine '\<\[\>'
  97. syn match forthDefine "\[']"
  98. syn match forthDefine '\[COMPILE]'
  99.  
  100. " debugging
  101. syn keyword forthDebug PRINTDEBUGDATA PRINTDEBUGLINE
  102. syn match forthDebug "\<\~\~\>"
  103.  
  104. " Assembler
  105. syn keyword forthAssembler ASSEMBLER CODE END-CODE ;CODE FLUSH-ICACHE C,
  106.  
  107. " basic character operations
  108. syn keyword forthCharOps (.) CHAR EXPECT FIND WORD TYPE -TRAILING EMIT KEY
  109. syn keyword forthCharOps KEY? TIB CR
  110. syn region forthCharOps start=+."\s+ skip=+\\"+ end=+"+
  111.  
  112. " char-number conversion
  113. syn keyword forthConversion <# # #> #S (NUMBER) (NUMBER?) CONVERT D>F D>S DIGIT
  114. syn keyword forthConversion DPL F>D HLD HOLD NUMBER S>D SIGN >NUMBER
  115.  
  116. " interptreter, wordbook, compiler
  117. syn keyword forthForth (LOCAL) BYE COLD ABORT >BODY >NEXT >LINK CFA >VIEW HERE
  118. syn keyword forthForth PAD WORDS VIEW VIEW> N>LINK NAME> LINK> L>NAME FORGET
  119. syn keyword forthForth BODY>
  120. syn region forthForth start=+ABORT"\s+ skip=+\\"+ end=+"+
  121.  
  122. " vocabularies
  123. syn keyword forthVocs ONLY FORTH ALSO ROOT SEAL VOCS ORDER CONTEXT #VOCS
  124. syn keyword forthVocs VOCABULARY DEFINITIONS
  125.  
  126. " numbers
  127. syn keyword forthMath DECIMAL HEX BASE
  128. syn match forthInteger '\<-\=[0-9.]*[0-9.]\+\>'
  129. syn match forthHex '\<[0-9a-fA-F]*[0-9][0-9a-fA-F]*\>'
  130. syn match forthFloat '\<-\=[0-9]*[.]\=[0-9]\+[Ee][0-9]\+\>'
  131.  
  132. " Strings
  133. syn region forthString start=+\.*\"+ end=+"+ end=+$+
  134.  
  135. " Comments
  136. syn match forthComment '\\\s.*$' contains=forthTodo
  137. syn region forthComment start='\\S\s' end='.*' contains=forthTodo
  138. syn match forthComment '\.(\s[^)]*)' contains=forthTodo
  139. syn region forthComment start='(\s' skip='\\)' end=')' contains=forthTodo
  140. "syn match forthComment '(\s[^\-]*\-\-[^\-]*)' contains=forthTodo
  141.  
  142. " Include files
  143. syn match forthInclude '^INCLUDE\s\+\k\+'
  144.  
  145. " Define the default highlighting.
  146. " For version 5.7 and earlier: only when not done already
  147. " For version 5.8 and later: only when an item doesn't have highlighting yet
  148. if version >= 508 || !exists("did_forth_syn_inits")
  149.     if version < 508
  150.         let did_forth_syn_inits = 1
  151.         command -nargs=+ HiLink hi link <args>
  152.     else
  153.         command -nargs=+ HiLink hi def link <args>
  154.     endif
  155.  
  156.     " The default methods for highlighting. Can be overriden later.
  157.     HiLink forthTodo Todo
  158.     HiLink forthOperators Operator
  159.     HiLink forthMath Number
  160.     HiLink forthInteger Number
  161.     HiLink forthFloat Float
  162.     HiLink forthStack Special
  163.     HiLink forthRstack Special
  164.     HiLink forthFStack Special
  165.     HiLink forthSP Special
  166.     HiLink forthMemory Function
  167.     HiLink forthAdrArith Function
  168.     HiLink forthMemBlks Function
  169.     HiLink forthCond Conditional
  170.     HiLink forthLoop Repeat
  171.     HiLink forthColonDef Define
  172.     HiLink forthEndOfColonDef Define
  173.     HiLink forthDefine Define
  174.     HiLink forthDebug Debug
  175.     HiLink forthAssembler Include
  176.     HiLink forthCharOps Character
  177.     HiLink forthConversion String
  178.     HiLink forthForth Statement
  179.     HiLink forthVocs Statement
  180.     HiLink forthString String
  181.     HiLink forthComment Comment
  182.  
  183.     delcommand HiLink
  184. endif
  185.  
  186. let b:current_syntax = "forth"
  187.  
  188. " vim:ts=3:sw=3
  189.